﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Code.Models;
using System.Text.RegularExpressions;

namespace Code.BLL.Arithmetic
{
    /// <summary>
    /// 前三直选 
    /// </summary>
    internal class QianSanZhiShuan : PlayTypeProduct
    {
        private PlayType_E PlayType { get; set; }
        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public QianSanZhiShuan(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.QianSanZhiXuan;
        }
        public QianSanZhiShuan(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }

        /// <summary>
        /// 根据用户提交的号码，如： 152，46，357 则可提出18注，分别为：143，145，147，163，165，167，543，545，547...
        /// 相应的提取方法见下面
        /// </summary>
        /// <param name="userChoseNumber"></param>
        /// <param name="openCode">开奖号码的前三位</param>
        /// <returns></returns>
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (_OpenCode.Length < 3)//判断开奖号码是否合格
                throw new ArgumentException("参数格式不正确" + _OpenCode, "openCode");
            if (userChoseNumber.Replace(",", "").Equals(_OpenCode))
                return new List<string> { _OpenCode };

            userChoseNumber = base._RegistNum(userChoseNumber);//判断用户选择的号码是否合格
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");
            _GetChoseNumberList(userChoseNumber);


            List<string> winNums = new List<string>();

            if (base.lotteryType == LotteryType.TC11X5)
                _OpenCode = _OpenCode.Replace(",", " ");
            foreach (var item in base.ChoseNumberList)
            {
                if (item.Equals(_OpenCode))//和开奖号码的前三位比较
                    winNums.Add(item);
            }

            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            var list = userChoseNumber.Split(new string[] { ", ", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            var num2 = list[1].ToString();
            var num3 = list[2].ToString();
            int count = 0;
           if (base.lotteryType != LotteryType.TC11X5){
                if (userChoseNumber.Replace(",", "").Length == 3)
                    return 1;
                var num = userChoseNumber.Split(',');
                if (num.Length != 3)
                    throw new ArgumentException();
                return num[0].Length * num[1].Length * num[2].Length;
            }
            else
            {
                if (userChoseNumber.Replace(",", "").Length == 3)
                    return 1;
                for (var i = 0; i < list[0].Split(' ').Length; i++)
                {
                    for (var j = 0; j < list[1].Split(' ').Length; j++)
                    {
                        for (var k = 0; k < list[2].Split(' ').Length; k++)
                        {
                            if (list[0].Split(' ')[i].ToString() != list[1].Split(' ')[j].ToString() && list[0].Split(' ')[i].ToString() != list[2].Split(' ')[k].ToString() && list[1].Split(' ')[j].ToString() != list[2].Split(' ')[k].ToString())
                                count += 1;
                        }
                    }
                }
                return count;
            }
           
            
           
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 前三组选 
    /// </summary>
    internal class QianSanZuShuan : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public QianSanZuShuan(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        /// <summary>
        /// 根据用户提交的号码获取中奖的号码，复式的格式为:345,235,753。单式的格式为：234
        /// </summary>
        /// <param name="userChoseNumber"></param>
        /// <param name="openCode">此玩法的开奖号码</param>
        /// <returns></returns>
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.QianSanZuXuan.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (_OpenCode.Length != 3)//判断开奖号码
                throw new ArgumentException("参数格式不正确" + _OpenCode, "openCode");

            if (userChoseNumber.Replace(",", "").Length == _OpenCode.Length)
                return GetWinNumsD(userChoseNumber.Replace(",", ""), _OpenCode);


            _GetChoseNumberList(userChoseNumber);

            userChoseNumber = base._RegistNum(userChoseNumber);//判断用户选择的号码是否合格
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");


            List<string> winNums = new List<string>();
            foreach (var item in base.ChoseNumberList)
            {
                winNums.AddRange(GetWinNumsD(item, _OpenCode));
            }
            return winNums;
        }
        //单式号码
        private IEnumerable<string> GetWinNumsD(string userChoseNumber, string openCodeStr)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (openCodeStr == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            List<string> winNums = new List<string>();
            //把用户选择的号码排序后和排序后的开奖号码比较，排序都为升序
            if (userChoseNumber.ToCharArray().SortToString(false).Equals(openCodeStr.ToCharArray().SortToString(false)))
                winNums.Add(userChoseNumber);

            return winNums;

        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            userChoseNumber = userChoseNumber.Replace(" ", "");
            if (userChoseNumber.Replace(",", "").Length == 3)
                return 1;
            var list = userChoseNumber.Split(',');
            if (list.Length != 3)
                throw new ArgumentException();
            return list[0].Length * list[1].Length * list[2].Length;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    ///  前三直和 
    /// </summary>
    internal class QianSanZhiHe : SumValueBase
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public QianSanZhiHe(Regex regDouble)
            : base(regDouble, PlayType_E.QianSanZhiHe)
        {
        }

    }
    /// <summary>
    /// 前三组和 
    /// </summary>
    internal class QianSanZuHe : SumValueBase
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public QianSanZuHe(Regex regDouble)
            : base(regDouble, PlayType_E.QianSanZuHe)
        {
        }
    }
    /// <summary>
    /// 后三直选 
    /// </summary>
    internal class HouSanZhiShuan : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public HouSanZhiShuan(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        /// <summary>
        /// 根据用户提交的号码，如： 152，46，357 则可提出18注，分别为：143，145，147，163，165，167，543，545，547...
        /// 相应的提取方法见下面
        /// </summary>
        /// <param name="userChoseNumber"></param>
        /// <param name="openCode"></param>
        /// <returns></returns>
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.HouSanZhiXuan.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (_OpenCode.Length != 3)//判断开奖号码是否合格
                throw new ArgumentException("参数格式不正确" + _OpenCode, "openCode");
            if (userChoseNumber.Replace(",", "").Equals(_OpenCode))
                return new List<string> { _OpenCode };


            _GetChoseNumberList(userChoseNumber);

            userChoseNumber = base._RegistNum(userChoseNumber);//判断用户选择的号码是否合格
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");

            List<string> winNums = new List<string>();

            foreach (var item in base.ChoseNumberList)
            {
                if (item.Equals(_OpenCode))//和开奖号码的后三位比较
                {
                    winNums.Add(item);
                }
            }

            return winNums;
        }


        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            userChoseNumber = userChoseNumber.Replace(" ", "");
            if (userChoseNumber.Replace(",", "").Length == 3)
                return 1;
            var list = userChoseNumber.Split(',');
            if (list.Length != 3)
                throw new ArgumentException();
            return list[0].Length * list[1].Length * list[2].Length;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 后三组选 
    /// </summary>
    internal class HouSanZuShuan : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public HouSanZuShuan(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        /// <summary>
        /// 根据用户提交的号码获取中奖的号码，复式的格式为：645，21，874。单式的格式为：156
        /// </summary>
        /// <param name="userChoseNumber"></param>
        /// <param name="openCode">此玩法的开奖号码</param>
        /// <param name="isComplexity">是否为复式</param>
        /// <returns></returns>
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.HouSanZuXuan.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (_OpenCode.Length != 3)//判断开奖号码是否合格
                throw new ArgumentException("参数格式不正确" + _OpenCode, "openCode");

            if (userChoseNumber.Replace(",", "").Length == 3)
                return GetWinNumsD(userChoseNumber.Replace(",", ""), _OpenCode);


            _GetChoseNumberList(userChoseNumber);

            userChoseNumber = base._RegistNum(userChoseNumber);//判断用户选择的复式号码是否合格
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");


            List<string> winNums = new List<string>();
            foreach (var item in base.ChoseNumberList)
            {
                winNums.AddRange(GetWinNumsD(item, _OpenCode));
            }
            return winNums;
        }
        //单式
        private IEnumerable<string> GetWinNumsD(string userChoseNumber, string openCodeStr)
        {
            if (userChoseNumber == null || openCodeStr == null)
                return new List<string>();

            List<string> winNums = new List<string>();
            //把用户选择的号码升序排序后和升序排序后的开奖号码进行比较
            if (userChoseNumber.ToCharArray().SortToString(false).Equals(openCodeStr.ToCharArray().SortToString(false)))
                winNums.Add(userChoseNumber);

            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            userChoseNumber = userChoseNumber.Replace(" ", "");
            if (userChoseNumber.Replace(",", "").Length == 3)
                return 1;
            var list = userChoseNumber.Split(',');
            if (list.Length != 3)
                throw new ArgumentException();
            return list[0].Length * list[1].Length * list[2].Length;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }
    /// <summary> 
    /// 后三直和 
    /// </summary>
    internal class HouSanZhiHe : SumValueBase
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public HouSanZhiHe(Regex regDouble)
            : base(regDouble, PlayType_E.HouSanZhiHe)
        {
        }
    }
    /// <summary>
    /// 后三组和  
    /// </summary>
    internal class HouSanZuHe : SumValueBase
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public HouSanZuHe(Regex regDouble)
            : base(regDouble, PlayType_E.HouSanZuHe)
        {
        }
    }
    /// <summary>
    /// 前二直选  
    /// </summary>
    internal class QianerZhiShuan : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public QianerZhiShuan(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }

        /// <summary>
        /// 根据用户提交的号码，如： 152，357 则可提出9注，分别为：13，15，17，53，55，57...
        /// 相应的提取方法见下面
        /// </summary>
        /// <param name="userChoseNumber"></param>
        /// <param name="openCode">开奖号码的前三位</param>
        /// <returns></returns>
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.QianerZhiXuan.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            if (base.lotteryType != LotteryType.TC11X5 && _OpenCode.Length != 2)//判断开奖号码是否合格
                throw new ArgumentException("参数格式不正确" + _OpenCode, "openCode");


            if (userChoseNumber.Replace(",", "").Equals(_OpenCode))
                return new List<string> { _OpenCode };

            userChoseNumber = base._RegistNum(userChoseNumber);//判断用户选择的号码是否合格
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");

            _GetChoseNumberList(userChoseNumber);

            List<string> winNums = new List<string>();

            if (base.lotteryType == LotteryType.TC11X5)
                _OpenCode = _OpenCode.Replace(",", " ");

            foreach (var item in base.ChoseNumberList)
            {
                if (item.Equals(_OpenCode))//和开奖号码的前三位比较
                {
                    winNums.Add(item);
                }
            }

            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            int count = 0;
            for (var i = 0; i < list[0].Split(' ').Length; i++)
            {
                for (var j = 0; j < list[1].Split(' ').Length; j++)
                {
                    if (list[0].Split(' ')[i].ToString() != list[1].Split(' ')[j].ToString())
                        count += 1;
                }
            }

            return count;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 前二组选  
    /// </summary>
    internal class QianerZuShuan : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public QianerZuShuan(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.QianerZuXuan.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (_OpenCode.Length != 2)
                throw new ArgumentException("参数格式不正确" + _OpenCode, "openCode");

            if (userChoseNumber.Replace(",", "").Length == 2)
                return GetWinNumsD(userChoseNumber.Replace(",", ""), _OpenCode);


            _GetChoseNumberList(userChoseNumber);

            userChoseNumber = base._RegistNum(userChoseNumber);//判断复式号码
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");


            List<string> winNums = new List<string>();
            foreach (var item in base.ChoseNumberList)
            {
                winNums.AddRange(GetWinNumsD(item, _OpenCode));
            }
            return winNums;
        }
        //单式
        private IEnumerable<string> GetWinNumsD(string userChoseNumber, string openCodeStr)
        {
            if (userChoseNumber == null || openCodeStr == null)
                return new List<string>();
            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");

            List<string> winNums = new List<string>();
            //将用户选择的号码进行升序排序和升序排序后的开将号码进行比较
            if (userChoseNumber.ToCharArray().SortToString(false).Equals(openCodeStr.ToCharArray().SortToString(false)))
                winNums.Add(userChoseNumber);

            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            userChoseNumber = userChoseNumber.Replace(" ", "");
            if (userChoseNumber.Replace(",", "").Length == 2)
                return 1;
            var list = userChoseNumber.Split(',');
            if (list.Length != 2)
                throw new ArgumentException();
            return list[0].Length * list[1].Length;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 直选和值  
    /// </summary>
    internal class ZhiShuanHeZhi : SumValueBase
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public ZhiShuanHeZhi(Regex regDouble)
            : base(regDouble, PlayType_E.ZhiXuanHeZhi)
        {
        }
    }
    /// <summary>
    /// 组选和值  
    /// </summary>
    internal class ZuShuanHeZhi : SumValueBase
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public ZuShuanHeZhi(Regex regDouble)
            : base(regDouble, PlayType_E.ZuXuanHeZhi)
        {
        }
    }
    /// <summary>
    /// 个位和值  
    /// </summary>
    internal class GeWeiHeZhi : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public GeWeiHeZhi(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }

        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            throw new Exception("此方法，尚未实现！");
        }


        protected override int _GetNumCount(string userChoseNumber)
        {
            throw new NotImplementedException();
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            throw new NotImplementedException();
        }
    }
    /// <summary> 
    /// 大小单双 
    /// </summary>
    internal class DaXiaoDanShuang : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public DaXiaoDanShuang(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        private List<string> GetWinNumsD(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (_OpenCode.Length != 2)
                throw new ArgumentException("参数格式不正确" + _OpenCode, "openCode");
            DaXiaoDanShuang_E param1;
            DaXiaoDanShuang_E param2;
            try
            {
                //将用户选择的号码强转成枚举
                param1 = (DaXiaoDanShuang_E)Enum.Parse(typeof(DaXiaoDanShuang_E), userChoseNumber[0].ToString());
                param2 = (DaXiaoDanShuang_E)Enum.Parse(typeof(DaXiaoDanShuang_E), userChoseNumber[1].ToString());
            }
            catch
            {
                throw new ArgumentException("参数格式不正确:" + userChoseNumber, "userChoseNumber");
            }
            List<string> winNums = new List<string>();

            if (DXDS(param1, param2, _OpenCode))//判断是否和开奖号码所在的区间相同
                winNums.Add(userChoseNumber);

            return winNums;
        }
        private bool DXDS(Code.Models.DaXiaoDanShuang_E param1, Code.Models.DaXiaoDanShuang_E param2, string openCode)
        {
            bool flag = false;

            int shi = int.Parse(openCode[0].ToString());//获取开奖号码的十位上的数
            int ge = int.Parse(openCode[1].ToString());//获取开奖号码的个位上的数
            bool b1 = false;
            bool b2 = false;
            switch (param1)//判断参数一是哪一个枚举值
            {
                case Code.Models.DaXiaoDanShuang_E.大:
                    b1 = shi >= 5;
                    break;
                case Code.Models.DaXiaoDanShuang_E.小:
                    b1 = shi < 5;
                    break;
                case Code.Models.DaXiaoDanShuang_E.单:
                    b1 = shi % 2 != 0;
                    break;
                case Code.Models.DaXiaoDanShuang_E.双:
                    b1 = shi % 2 == 0;
                    break;
            }
            switch (param2)
            {
                case Code.Models.DaXiaoDanShuang_E.大:
                    b2 = ge >= 5;
                    break;
                case Code.Models.DaXiaoDanShuang_E.小:
                    b2 = ge < 5;
                    break;
                case Code.Models.DaXiaoDanShuang_E.单:
                    b2 = ge % 2 != 0;
                    break;
                case Code.Models.DaXiaoDanShuang_E.双:
                    b2 = ge % 2 == 0;
                    break;
            }

            flag = b1 && b2;

            return flag;
        }

        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.DaXiaoDanShuan.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null || _OpenCode == null)
                return new List<string>();
            userChoseNumber = base._RegistNum(userChoseNumber);//判断用户选择的号码
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");

            _GetChoseNumberList(userChoseNumber);

            List<string> winNums = new List<string>();
            foreach (var item in base.ChoseNumberList)
            {
                winNums.AddRange(GetWinNumsD(item));
            }
            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();

            userChoseNumber = userChoseNumber.Replace(" ", "");
            var numList = userChoseNumber.Split(',');
            return numList[0].Length * numList[1].Length;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 三星定位胆
    /// </summary>
    internal abstract class SanXingDingWeiDan : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        private PlayType_E _Type;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public SanXingDingWeiDan(Regex regDouble, PlayType_E type)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;

            _Type = type;
        }
        /// <summary>
        /// 用户选择的号码的格式为：复式 ,,123 或者 ,123, 或者 123,, 单式 ,,1 或者 ,1, 或者 1,,
        /// </summary>
        /// <param name="userChoseNumber"></param>
        /// <param name="openCode"></param>
        /// <returns></returns>
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = _Type.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            userChoseNumber = base._RegistNum(userChoseNumber);//检验用户选择的号码，返回带有标识的号码
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");
            if (_OpenCode.Length != 3)
                throw new ArgumentException("参数格式不正确" + _OpenCode, "openCode");

            List<string> winNums = new List<string>();

            var nums = userChoseNumber.Split(',');
            if (nums.Length != 3)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");
            for (int i = 0; i < nums.Length; i++)
            {
                if (nums[i].Contains(_OpenCode[i]))
                {
                    winNums.Add(_OpenCode[i].ToString());
                }
            }

            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            userChoseNumber = userChoseNumber.Replace(" ", "");
            return userChoseNumber.Length - 2;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = userChoseNumber.Where(p => p != ',').Select(p => p.ToString()).ToList();
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 三星不定位胆
    /// </summary>
    internal abstract class SanXingBuDingWeiDan : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        private PlayType_E _Type;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public SanXingBuDingWeiDan(Regex regDouble, PlayType_E type)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;

            _Type = type;
        }
        /// <summary>
        /// 用户选择的号码的
        /// </summary>
        /// <param name="userChoseNumber"></param>
        /// <param name="openCode"></param>
        /// <returns></returns>
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = _Type.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");

            if (_OpenCode.Length != 3)
                throw new ArgumentException("参数格式不正确" + _OpenCode, "openCode");

            List<string> winNums = new List<string>();

            foreach (var item in _OpenCode)//判断开奖号码的后三位中是否存在于用户选择的号码中，有则表示用户中奖
            {
                if (userChoseNumber.IndexOf(item) >= 0)
                {
                    userChoseNumber = userChoseNumber.Replace(item.ToString(),"");
                    winNums.Add(item.ToString());
                }
            }

            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            userChoseNumber = userChoseNumber.Replace(" ", "");
            return userChoseNumber.Length;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = userChoseNumber.Select(s => s.ToString()).ToList();
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 定位胆
    /// (五星定位胆)
    /// </summary>
    internal class WuXinDingWeiDan : PlayTypeProduct
    {
        private string _OpenCode;
        public WuXinDingWeiDan(Regex regex)
            : base(regex) { }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            if (string.IsNullOrEmpty(openCode))
                throw new ArgumentNullException("openCode");
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException("userChoseNumber");
            _OpenCode = PlayType_E.DingWeiDan.GetOpenCode(openCode, base.lotteryType);
            if (_OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确!", "openCode");

            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确!", "userChoseNumber");

            var list = userChoseNumber.Split(',');
            if (list.Length != 5)
                throw new ArgumentException("参数格式不正确,必须为五星号码且用','隔开!", "userChoseNumber");
            List<string> winNums = new List<string>();
            for (int i = 0; i < list.Length; i++)
            {
                var c = _OpenCode[i];
                if (list[i].Contains(c))
                    winNums.Add(c.ToString());
            }
            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            userChoseNumber = userChoseNumber.Replace(" ", "");
            var list = userChoseNumber.Split(',');
            if (list.Length != 5)
                throw new ArgumentException();
            return list.Sum(p => p.Length);
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = userChoseNumber.Where(p => p != ',').Select(p => p.ToString()).ToList();
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 后三定位胆
    /// </summary>
    internal class HouSanDingWeiDan : SanXingDingWeiDan
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public HouSanDingWeiDan(Regex regDouble)
            : base(regDouble, PlayType_E.HouSanDingWeiDan)
        {

        }
    }
    /// <summary>
    /// 后三不定位胆
    /// </summary>
    internal class HouSanBuDingWeiDan : SanXingBuDingWeiDan
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public HouSanBuDingWeiDan(Regex regDouble)
            : base(regDouble, PlayType_E.HouSanBuDingWeiDan)
        {

        }
    }
    /// <summary>
    /// 前三不定位胆
    /// </summary>
    internal class QianSanBuDingWeiDan : SanXingBuDingWeiDan
    {
        public QianSanBuDingWeiDan(Regex regex)
            : base(regex, PlayType_E.QianSanBuDingWeiDan)
        {
        }
    }
    /// <summary>
    /// 前三定位胆
    /// </summary>
    //internal class QianSanDingWeiDan : SanXingDingWeiDan
    //{
    //    private string _OpenCode = "";
    //    /// <summary>
    //    /// 构造函数
    //    /// </summary>
    //    /// <param name="regDouble">复式的号码格式</param>
    //    /// <param name="regSingle">单式的号码格式</param>
    //    /// <param name="openCode">开奖号码</param>
    //    public QianSanDingWeiDan(Regex regDouble)
    //        : base(regDouble,PlayType_E.QianSanDingWeiDan)
    //    {

    //    }
    //    protected override string GetOpenCodeNum(int type)
    //    {
    //        if (_OpenCode == null || _OpenCode == "")
    //            throw new ArgumentException("参数格式不正确"+_OpenCode, "openCode");
    //        return _OpenCode.Substring(3 - type, 1);
    //    }

    //    protected override string GetOpenCodeNum(int type, string openCode)
    //    {
    //        throw new NotImplementedException();
    //    }
    //}

    /// <summary>
    /// 前一 
    /// </summary>
    internal class QianYi : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public QianYi(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.QianYi.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");
            if (_OpenCode.Length < 1)
                throw new ArgumentException("参数格式不正确" + _OpenCode, "openCode");
            List<string> winNums = new List<string>();
            foreach (var item in userChoseNumber)
            {
                if (_OpenCode.Equals(item.ToString()))//用户选择的每一个号码与开奖号码的前一位比较
                    winNums.Add(item.ToString());
            }
            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            userChoseNumber = userChoseNumber.Replace(" ", "");
            return userChoseNumber.Length;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = userChoseNumber.Select(p => p.ToString()).ToList();
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 后一 
    /// </summary>
    internal class HouYi : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public HouYi(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.HouYi.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");
            if (_OpenCode.Length < 1)
                throw new ArgumentException("参数格式不正确" + _OpenCode, "openCode");
            List<string> winNums = new List<string>();
            foreach (var item in userChoseNumber)
            {
                if (_OpenCode.Equals(item.ToString()))//用户选择的号码的每一位与开奖号码的最后一位进行比较
                    winNums.Add(item.ToString());
            }
            return winNums;
        }
        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            userChoseNumber = userChoseNumber.Replace(" ", "");
            return userChoseNumber.Length;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = userChoseNumber.Select(p => p.ToString()).ToList();
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 前二 
    /// </summary>
    internal class Qianer : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public Qianer(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        /// <summary>
        /// 用户选择的号码格式为：复式，345，567。单式，23
        /// </summary>
        /// <param name="userChoseNumber"></param>
        /// <param name="openCode"></param>
        /// <returns></returns>
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.Qianer.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (_OpenCode.Length != 2)
                throw new ArgumentException("参数格式不正确" + _OpenCode, "openCode");

            if (userChoseNumber.Replace(",", "").Equals(_OpenCode))
                return new List<string> { _OpenCode };

            List<string> winNums = new List<string>();

            _GetChoseNumberList(userChoseNumber);

            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");


            foreach (var item in base.ChoseNumberList)
            {
                if (item.Equals(_OpenCode))//和开奖号码的前二位比较
                {
                    winNums.Add(item);
                }
            }

            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            userChoseNumber = userChoseNumber.Replace(" ", "");
            if (userChoseNumber.Replace(",", "").Length == 2)
                return 1;
            var list = userChoseNumber.Split(',');
            if (list.Length != 2)
                throw new ArgumentException();
            return list[0].Length * list[1].Length;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 后二 
    /// </summary>
    internal class Houer : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public Houer(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.Houer.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (_OpenCode.Length != 2)
                throw new ArgumentException("参数格式不正确" + _OpenCode, "openCode");

            if (userChoseNumber.Replace(",", "").Equals(_OpenCode))
                return new List<string> { _OpenCode };

            List<string> winNums = new List<string>();

            _GetChoseNumberList(userChoseNumber);

            userChoseNumber = base._RegistNum(userChoseNumber);//验证号码
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");


            foreach (var item in base.ChoseNumberList)
            {
                if (item.Equals(_OpenCode))//和开奖号码的后二位比较
                {
                    winNums.Add(item);
                }
            }

            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            userChoseNumber = userChoseNumber.Replace(" ", "");
            if (userChoseNumber.Replace(",", "").Length == 2)
                return 1;
            var list = userChoseNumber.Split(',');
            if (list.Length != 2)
                throw new ArgumentException();
            return list[0].Length * list[1].Length;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 直选 
    /// </summary>
    internal class ZhiShuan : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public ZhiShuan(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.ZhiXuan.GetOpenCode(openCode, base.lotteryType);
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (string.IsNullOrEmpty(_OpenCode))
                throw new ArgumentException("参数格式不正确", "openCode");

            if (userChoseNumber.Replace(",", "").Equals(_OpenCode))
                return new List<string> { _OpenCode };


            _GetChoseNumberList(userChoseNumber);

            List<string> winNums = new List<string>();
            foreach (var item in base.ChoseNumberList)
            {
                if (item.Equals(_OpenCode))
                    winNums.Add(item);
            }

            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            _GetChoseNumberList(userChoseNumber);
            return base.ChoseNumberList.Count;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 组选 
    /// </summary>
    internal class ZuShuan : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public ZuShuan(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;
        }

        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.ZuXuan.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            userChoseNumber = base._RegistNum(userChoseNumber);//验证用户输入的号码
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确", "userChoseNumber");


            //将复式号码转换为单式


            _GetChoseNumberList(userChoseNumber);

            List<string> winNums = new List<string>();
            foreach (var item in base.ChoseNumberList)
            {
                if (item.ToCharArray().SortToString(false).Equals(_OpenCode.ToCharArray().SortToString(false)))
                    winNums.Add(item);
            }
            return winNums;
        }


        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            List<string> nums = new List<string>();
            var length = userChoseNumber.Split(',').Length;
            ManipulateNumber.GetNumList(userChoseNumber, new int[length], nums);
            return nums.Count;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            var nums = new List<string>();
            ManipulateNumber.GetNumList(userChoseNumber, new int[_OpenCode.Length], nums);
            base.ChoseNumberList = nums;
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 组六
    /// </summary>
    internal class ZuLiu : PlayTypeProduct
    {
        protected PlayType_E PlayType { get; set; }
        private string _OpenCode;
        public ZuLiu(Regex regDouble)
            : base(regDouble) { PlayType = PlayType_E.ZuLiu; }
        public ZuLiu(Regex regDouble, PlayType_E playType)
            : base(regDouble) { PlayType = playType; }


        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");


            userChoseNumber = base._RegistNum(userChoseNumber);//验证用户输入的号码
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确", "userChoseNumber");

            _GetChoseNumberList(userChoseNumber);

            List<string> winNums = new List<string>();

            foreach (var num in base.ChoseNumberList)
            {
                if (base.lotteryType == LotteryType.TC11X5)
                {
                    if (num.Split(' ').All(p => _OpenCode.Contains(p)))
                        winNums.Add(num);
                }
                else
                    if (num.All(p => _OpenCode.Contains(p)))
                        winNums.Add(num);
            }
            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            if (base.lotteryType == LotteryType.TC11X5)
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "");
            else if (userChoseNumber.Length > 10)
                throw new ArgumentException();
            userChoseNumber = userChoseNumber.Replace(" ", "");
            int[] counts = new int[] { 0, 0, 0, 1, 4, 10, 20, 35, 56, 84, 120, 165 };
            return counts[userChoseNumber.Length];
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            var nums = new List<string>();
            if (base.lotteryType == LotteryType.TC11X5)
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
            ManipulateNumber.GetNumList(userChoseNumber, new int[3], nums);
            if (base.lotteryType == LotteryType.TC11X5)
                base.ChoseNumberList = nums.Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            else
                base.ChoseNumberList = nums;
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 组二
    /// </summary>
    internal class ZuEr : PlayTypeProduct
    {
        protected PlayType_E PlayType { get; set; }
        private string _OpenCode;
        public ZuEr(Regex regDouble)
            : base(regDouble) { PlayType = PlayType_E.QianerZuXuan; }
        public ZuEr(Regex regDouble, PlayType_E playType)
            : base(regDouble) { PlayType = playType; }


        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            userChoseNumber = base._RegistNum(userChoseNumber);//验证用户输入的号码
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确", "userChoseNumber");

            _GetChoseNumberList(userChoseNumber);
            List<string> winNums = new List<string>();

            foreach (var num in base.ChoseNumberList)
            {
                if (base.lotteryType == LotteryType.TC11X5)
                {
                    if (num.Split(' ').All(p => _OpenCode.Contains(p)))
                        winNums.Add(num);
                }
                else
                    if (num.All(p => _OpenCode.Contains(p)))
                        winNums.Add(num);
            }
            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            if (base.lotteryType == LotteryType.TC11X5)
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "");
            else if (userChoseNumber.Length > 10)
                throw new ArgumentException();
            userChoseNumber = userChoseNumber.Replace(" ", "");
            int[] counts = new int[] { 0, 0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55 };
            return counts[userChoseNumber.Length];
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            var nums = new List<string>();
            if (base.lotteryType == LotteryType.TC11X5)
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
            ManipulateNumber.GetNumList(userChoseNumber, new int[2], nums);
            if (base.lotteryType == LotteryType.TC11X5)
                base.ChoseNumberList = nums.Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            else
                base.ChoseNumberList = nums;
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 组三
    /// </summary>
    internal class ZuSan : PlayTypeProduct
    {
        protected PlayType_E PlayType { get; set; }
        private string _OpenCode;
        public ZuSan(Regex regex)
            : base(regex) { PlayType = PlayType_E.ZuSan; }
        private Regex reg = new Regex(@"^(?<num>\d)\k<num>(?!\k<num>)\d$|^(?<num1>\d)(?!\k<num1>)(?<num2>\d)\k<num2>$|^(?<num>\d)(?!\k<num>)\d\k<num>$");
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            userChoseNumber = base._RegistNum(userChoseNumber);//验证用户输入的号码
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确", "userChoseNumber");

            var sortcode = _OpenCode.ToArray().SortToString(false);
            List<string> winNums = new List<string>();
            if (reg.IsMatch(userChoseNumber))
            {
                if (userChoseNumber.ToArray().SortToString(false).Equals(sortcode))
                    winNums.Add(userChoseNumber);
                return winNums;
            }

            _GetChoseNumberList(userChoseNumber);
            foreach (var num in base.ChoseNumberList)
            {
                if (num.ToArray().SortToString(false).Equals(sortcode))
                {
                    winNums.Add(_OpenCode);
                }
            }
            return winNums;

        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            if (reg.IsMatch(userChoseNumber))
                return 1;
            if (userChoseNumber.Length < 2)
                return 0;
            userChoseNumber = userChoseNumber.Replace(" ", "");
            return userChoseNumber.Length * (userChoseNumber.Length - 1);
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (reg.IsMatch(userChoseNumber))
            {
                var list = new List<string> { userChoseNumber };
                base.ChoseNumberList = list;
                return base.ChoseNumberList;
            }
            var nums = new List<string>();
            ManipulateNumber.GetNumList(userChoseNumber, new int[2], nums);
            base.ChoseNumberList = nums.Select(p => "" + p[0] + p[0] + p[1]).ToList();
            base.ChoseNumberList.AddRange(nums.Select(p => "" + p[0] + p[1] + p[1]));
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 前三组三
    /// </summary>
    internal class QianSanZuSan : ZuSan
    {
        public QianSanZuSan(Regex regex)
            : base(regex)
        {
            base.PlayType = PlayType_E.QianSanZuSan;
        }
    }
    /// <summary>
    /// 前三组六
    /// </summary>
    internal class QianSanZuLiu : ZuLiu
    {
        public QianSanZuLiu(Regex regex)
            : base(regex)
        {
            base.PlayType = PlayType_E.QianSanZuLiu;
        }
    }
    /// <summary>
    /// 后三组三
    /// </summary>
    internal class HouSanZuSan : ZuSan
    {
        public HouSanZuSan(Regex regex)
            : base(regex)
        {
            base.PlayType = PlayType_E.HouSanZuSan;
        }
    }
    /// <summary>
    /// 后三组六
    /// </summary>
    internal class HouSanZuLiu : ZuLiu
    {
        public HouSanZuLiu(Regex regex)
            : base(regex)
        {
            base.PlayType = PlayType_E.HouSanZuLiu;
        }
    }
    /// <summary>
    /// 和值 
    /// </summary>
    internal class SumValueBase : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        private PlayType_E _Type;
        private int[] _NumsCount = new int[] { 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 63, 69, 73, 75, 75, 73, 69, 63, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1 };
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public SumValueBase(Regex regDouble, PlayType_E type)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;
            _Type = type;
        }

        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = _Type.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");

            var openCodeSum = GetOpenCodeSum(_OpenCode);//获取子类开奖号码的和

            List<string> winNums = new List<string>();
            string[] nums = userChoseNumber.Split(',');
            foreach (var item in nums)
            {
                if (int.Parse(item) == openCodeSum)
                    winNums.Add(item);
            }
            return winNums;
        }
        private int GetOpenCodeSum(string openCode)
        {
            if (string.IsNullOrEmpty(openCode))
                throw new ArgumentNullException("openCode", "参数不能为空值");
            else
            {
                int sum = 0;
                foreach (var item in openCode)
                {
                    int i;
                    if (!int.TryParse(item.ToString(), out i))
                    {
                        throw new ArgumentException("参数格式不正确", "openCode");
                    }
                    sum += i;
                }
                return sum;
            }
        }


        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            var count = 0;
            var list = userChoseNumber.Split(',');
            for (int i = 0; i < list.Length; i++)
            {
                int n;
                if (int.TryParse(list[i], out n))
                {
                    try
                    {
                        count += _NumsCount[n];
                    }
                    catch (Exception)
                    {
                        throw new ArgumentException("参数格式不正确:" + userChoseNumber);
                    }
                }
                else
                    throw new ArgumentException("参数格式不正确:" + userChoseNumber);
            }
            return count;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = userChoseNumber.Split(',').ToList();
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 二星和值
    /// </summary>
    //internal class ErXingSumValue : SumValueBase
    //{
    //    public ErXingSumValue(Regex regDouble)
    //        : base(regDouble,PlayType_E.ErXingSumValue)
    //    {
    //    }
    //}
    /// <summary>
    /// 三星和值
    /// </summary>
    //internal class SanXingSumValue : SumValueBase
    //{
    //    public SanXingSumValue(Regex regDouble)
    //        : base(regDouble,PlayType_E.SanXingSumValue)
    //    {
    //    }
    //}
    /// <summary>
    /// 组和 
    /// </summary>
    internal class ZuHe : SumValueBase
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public ZuHe(Regex regDouble)
            : base(regDouble, PlayType_E.ZuHe)
        {
        }
    }
    /// <summary>
    /// 值和 
    /// </summary>
    internal class ZhiHe : SumValueBase
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public ZhiHe(Regex regDouble)
            : base(regDouble, PlayType_E.ZhiHe)
        {
        }
    }
    /// <summary>
    /// 合值 
    /// </summary>
    internal class HeZhiBase : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        private PlayType_E _Type;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public HeZhiBase(Regex regDouble, PlayType_E type)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;

            _Type = type;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = _Type.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            string openCodeSum = GetOpenCodeSum(_OpenCode);

            string[] nums = userChoseNumber.Split(',');
            foreach (var item in nums)
            {
                if (item.Equals(openCodeSum.Substring(openCodeSum.Length - 1)))
                    return new List<string>() { userChoseNumber };
            }
            if (userChoseNumber.Equals(openCodeSum.Substring(openCodeSum.Length - 1)))
                return new List<string>() { userChoseNumber };
            return new List<string>();
        }
        private string GetOpenCodeSum(string openCode)
        {
            if (openCode == null)
                throw new ArgumentNullException("openCode", "参数不能为空值");
            if (openCode == "")
                return "";
            else
            {
                int sum = 0;
                foreach (var item in openCode)
                {
                    int i;
                    if (!int.TryParse(item.ToString(), out i))
                    {
                        throw new ArgumentException("参数格式不正确", "openCode");
                    }
                    sum += i;
                }
                return sum.ToString();
            }
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            return userChoseNumber.Split(',').Length;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            base.ChoseNumberList = userChoseNumber.Split(',').ToList();
            return base.ChoseNumberList;
        }
    }
    ///// <summary>
    ///// 三星合值
    ///// </summary>
    //internal class SanXingHeZhi : HeZhiBase
    //{
    //    public SanXingHeZhi(Regex regDouble)
    //        : base(regDouble,PlayType_E.SanXingHeZhi)
    //    { }
    //}
    /// <summary>
    /// 任选1 
    /// </summary>
    internal class Chose1 : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public Chose1(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }

        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.Chose1.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");
            if (base.lotteryType != LotteryType.TC11X5 && _OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");
            List<string> winNums = new List<string>();
            if (base.lotteryType == LotteryType.TC11X5)
            {
                if (userChoseNumber.Contains(_OpenCode))
                    winNums.Add(_OpenCode);
                return winNums;
            }
            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            if (base.lotteryType == LotteryType.TC11X5)
                return userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "").Length;
            userChoseNumber = userChoseNumber.Replace(" ", "");
            return userChoseNumber.Length;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
                base.ChoseNumberList = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Select(p => p == 'a' ? "10" : p == 'b' ? "11" : p.ToString()).ToList();
            else
                base.ChoseNumberList = userChoseNumber.Select(p => p.ToString()).ToList();
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 任选2 
    /// </summary>
    internal class Chose2 : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public Chose2(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        //单式
        private List<string> GetWinNumsD(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            if (_OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");
            int index1 = _OpenCode.IndexOf(userChoseNumber[0]);
            int index2 = _OpenCode.IndexOf(userChoseNumber[1]);
            if (index1 == index2)
                index2 = _OpenCode.IndexOf(userChoseNumber[1], index1 + 1);

            if (index1 < 0 || index2 < 0)
                return new List<string>();
            else
                return new List<string>() { userChoseNumber };
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.Chose2.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");


            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");

            if (base.lotteryType != LotteryType.TC11X5 && _OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");

            _GetChoseNumberList(userChoseNumber);

            List<string> winNums = new List<string>();

            foreach (var item in base.ChoseNumberList)
            {
                if (base.lotteryType == LotteryType.TC11X5)
                {
                    var flag = item.Split(' ').All(p => _OpenCode.Contains(p));
                    if (flag)
                        winNums.Add(item);
                    continue;
                }
                ////判断所购买的号码是否有中奖
                //if (GetWinNumsD(item).Count > 0)
                //    winNums.Add(item);
            }
            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();

            if (base.lotteryType == LotteryType.TC11X5)
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "");

            userChoseNumber = userChoseNumber.Replace(" ", "");
            List<string> nums = new List<string>();
            ManipulateNumber.GetNumList(userChoseNumber, new int[2], nums);
            return nums.Count;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                var str = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                var nums = new List<string>();
                ManipulateNumber.GetNumList(str, new int[2], nums);
                base.ChoseNumberList = nums.Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
            {
                var nums = new List<string>();
                ManipulateNumber.GetNumList(userChoseNumber, new int[2], nums);
                base.ChoseNumberList = nums;
            }
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 任选3 
    /// </summary>
    internal class Chose3 : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public Chose3(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        //单式
        private List<string> GetWinNumsD(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");


            if (_OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");
            List<string> winNums = new List<string>();

            int count = 0;
            foreach (var item in userChoseNumber)
            {
                if (_OpenCode.IndexOf(item) >= 0)
                    count++;
            }

            if (count == 3)
                winNums.Add("1&" + userChoseNumber);//表示一等奖
            if (count == 2)
                winNums.Add("2&" + userChoseNumber);//表示二等奖

            return winNums;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.Chose3.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");


            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");
            if (base.lotteryType != LotteryType.TC11X5 && _OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");

            List<string> winNums = new List<string>();


            _GetChoseNumberList(userChoseNumber);

            foreach (var item in base.ChoseNumberList)
            {
                if (base.lotteryType == LotteryType.TC11X5)
                {
                    var flag = item.Split(' ').All(p => _OpenCode.Contains(p));
                    if (flag)
                        winNums.Add(item);
                    continue;
                }
            }

            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            if (base.lotteryType == LotteryType.TC11X5)
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "");
            userChoseNumber = userChoseNumber.Replace(" ", "");
            List<string> nums = new List<string>();
            ManipulateNumber.GetNumList(userChoseNumber, new int[3], nums);
            return nums.Count;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                var str = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                var nums = new List<string>();
                ManipulateNumber.GetNumList(str, new int[3], nums);
                base.ChoseNumberList = nums.Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
            {
                var nums = new List<string>();
                ManipulateNumber.GetNumList(userChoseNumber, new int[3], nums);
                base.ChoseNumberList = nums;
            }
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 任选4 
    /// </summary>
    internal class Chose4 : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public Chose4(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        private List<string> GetWinNumsD(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            if (_OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");
            List<string> winNums = new List<string>();
            int count = 0;
            foreach (var item in userChoseNumber)
            {
                if (_OpenCode.IndexOf(item) >= 0)
                    count++;
            }
            if (count == 4)
                winNums.Add("1&" + userChoseNumber);//表示一等奖
            if (count == 3)
                winNums.Add("2&" + userChoseNumber);//表示二等奖
            return winNums;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.Chose4.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");
            if (base.lotteryType != LotteryType.TC11X5 && _OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");

            List<string> winNums = new List<string>();

            _GetChoseNumberList(userChoseNumber);

            foreach (var item in base.ChoseNumberList)
            {
                if (base.lotteryType == LotteryType.TC11X5)
                {
                    var flag = item.Split(' ').All(p => _OpenCode.Contains(p));
                    if (flag)
                        winNums.Add(item);
                    continue;
                }
            }

            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            if (base.lotteryType == LotteryType.TC11X5)
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "");
            userChoseNumber = userChoseNumber.Replace(" ", "");
            List<string> nums = new List<string>();
            ManipulateNumber.GetNumList(userChoseNumber, new int[4], nums);
            return nums.Count;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                var str = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                var nums = new List<string>();
                ManipulateNumber.GetNumList(str, new int[4], nums);
                base.ChoseNumberList = nums.Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
            {
                var nums = new List<string>();
                ManipulateNumber.GetNumList(userChoseNumber, new int[4], nums);
                base.ChoseNumberList = nums;
            }
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 任选5 
    /// </summary>
    internal class Chose5 : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public Chose5(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        private List<string> GetWinNumsD(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            if (_OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");
            List<string> winNums = new List<string>();
            int count = 0;
            foreach (var item in userChoseNumber)
            {
                if (_OpenCode.IndexOf(item) >= 0)
                    count++;
            }
            if (count == 5)
                winNums.Add("1&" + userChoseNumber);//表示一等奖
            if (count == 4)
                winNums.Add("2&" + userChoseNumber);//表示二等奖
            if (count == 3)
                winNums.Add("3&" + userChoseNumber);//表示三等奖
            return winNums;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.Chose5.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");
            if (base.lotteryType != LotteryType.TC11X5 && _OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");

            List<string> winNums = new List<string>();

            _GetChoseNumberList(userChoseNumber);

            foreach (var item in base.ChoseNumberList)
            {
                if (base.lotteryType == LotteryType.TC11X5)
                {
                    var flag = item.Split(' ').All(p => _OpenCode.Contains(p));
                    if (flag)
                        winNums.Add(item);
                    continue;
                }
            }

            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            if (base.lotteryType == LotteryType.TC11X5)
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "");
            userChoseNumber = userChoseNumber.Replace(" ", "");
            List<string> nums = new List<string>();
            ManipulateNumber.GetNumList(userChoseNumber, new int[5], nums);
            return nums.Count;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                var str = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                var nums = new List<string>();
                ManipulateNumber.GetNumList(str, new int[5], nums);
                base.ChoseNumberList = nums.Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
            {
                var nums = new List<string>();
                ManipulateNumber.GetNumList(userChoseNumber, new int[5], nums);
                base.ChoseNumberList = nums;
            }
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 任选6 
    /// </summary>
    internal class Chose6 : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public Chose6(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        //单式
        private List<string> GetWinNumsD(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            if (_OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");
            List<string> winNums = new List<string>();

            List<string> nums = new List<string>();
            ManipulateNumber.GetNumList(userChoseNumber, new int[5], nums);//获取单式号码中的任意5位的列表

            foreach (var item in nums)
            {
                if (item.Equals(_OpenCode))
                    winNums.Add(userChoseNumber);
            }

            return winNums;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.Chose6.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");
            if (base.lotteryType != LotteryType.TC11X5 && _OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");
            List<string> winNums = new List<string>();
            _GetChoseNumberList(userChoseNumber);

            foreach (var item in base.ChoseNumberList)
            {
                if (base.lotteryType == LotteryType.TC11X5)
                {
                    var flag = _OpenCode.Split(',').All(p => item.Contains(p));
                    if (flag)
                        winNums.Add(item);
                    continue;
                }
            }
            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            if (base.lotteryType == LotteryType.TC11X5)
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "");
            userChoseNumber = userChoseNumber.Replace(" ", "");
            List<string> nums = new List<string>();
            ManipulateNumber.GetNumList(userChoseNumber, new int[6], nums);
            return nums.Count;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                var str = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                var nums = new List<string>();
                ManipulateNumber.GetNumList(str, new int[6], nums);
                base.ChoseNumberList = nums.Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
            {
                var nums = new List<string>();
                ManipulateNumber.GetNumList(userChoseNumber, new int[6], nums);
                base.ChoseNumberList = nums;
            }
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 任选7 
    /// </summary>
    internal class Chose7 : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public Chose7(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        private List<string> GetWinNumsD(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            if (_OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");
            List<string> winNums = new List<string>();

            List<string> nums = new List<string>();
            ManipulateNumber.GetNumList(userChoseNumber, new int[5], nums);//获取单式号码中的任意5位的列表

            foreach (var item in nums)
            {
                if (item.Equals(_OpenCode))
                    winNums.Add(userChoseNumber);
            }

            return winNums;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.Chose7.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");
            if (base.lotteryType != LotteryType.TC11X5 && _OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");
            List<string> winNums = new List<string>();
            _GetChoseNumberList(userChoseNumber);

            foreach (var item in base.ChoseNumberList)
            {
                if (base.lotteryType == LotteryType.TC11X5)
                {
                    var flag = _OpenCode.Split(',').All(p => item.Contains(p));
                    if (flag)
                        winNums.Add(item);
                    continue;
                }
            }
            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            if (base.lotteryType == LotteryType.TC11X5)
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "");
            userChoseNumber = userChoseNumber.Replace(" ", "");
            List<string> nums = new List<string>();
            ManipulateNumber.GetNumList(userChoseNumber, new int[7], nums);
            return nums.Count;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                var str = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                var nums = new List<string>();
                ManipulateNumber.GetNumList(str, new int[7], nums);
                base.ChoseNumberList = nums.Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
            {
                var nums = new List<string>();
                ManipulateNumber.GetNumList(userChoseNumber, new int[7], nums);
                base.ChoseNumberList = nums;
            }
            return base.ChoseNumberList;
        }
    }
    /// <summary>
    /// 任选8 
    /// </summary>
    internal class Chose8 : PlayTypeProduct
    {
        private Regex _UserChoseDoubleNumberFormat;

        private string _OpenCode;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        /// <param name="regSingle">单式的号码格式</param>
        /// <param name="openCode">开奖号码</param>
        public Chose8(Regex regDouble)
            : base(regDouble)
        {
            this._UserChoseDoubleNumberFormat = regDouble;


        }
        private List<string> GetWinNumsD(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            if (_OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");
            List<string> winNums = new List<string>();

            List<string> nums = new List<string>();
            ManipulateNumber.GetNumList(userChoseNumber, new int[5], nums);//获取单式号码中的任意5位的列表

            foreach (var item in nums)
            {
                if (item.Equals(_OpenCode))
                    winNums.Add(userChoseNumber);
            }

            return winNums;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.Chose8.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            userChoseNumber = base._RegistNum(userChoseNumber);
            if (userChoseNumber == null)
                throw new ArgumentException("参数格式不正确" + userChoseNumber, "userChoseNumber");
            if (base.lotteryType != LotteryType.TC11X5 && _OpenCode.Length != 5)
                throw new ArgumentException("参数格式不正确", "openCode！");
            List<string> winNums = new List<string>();
            _GetChoseNumberList(userChoseNumber);

            foreach (var item in base.ChoseNumberList)
            {
                if (base.lotteryType == LotteryType.TC11X5)
                {
                    var flag = _OpenCode.Split(',').All(p =>item.Contains(p));
                    if (flag)
                        winNums.Add(item);
                    continue;
                }
            }
            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            if (base.lotteryType == LotteryType.TC11X5)
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "");
            userChoseNumber = userChoseNumber.Replace(" ", "");
            List<string> nums = new List<string>();
            ManipulateNumber.GetNumList(userChoseNumber, new int[8], nums);
            return nums.Count;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                var str = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                var nums = new List<string>();
                ManipulateNumber.GetNumList(str, new int[8], nums);
                base.ChoseNumberList = nums.Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
            {
                var nums = new List<string>();
                ManipulateNumber.GetNumList(userChoseNumber, new int[8], nums);
                base.ChoseNumberList = nums;
            }
            return base.ChoseNumberList;
        }
    }






}
